
import hce.core.composition.Composition

/**
 * @author Pablo Pazos Gutierrez (pablo.swp@gmail.com)
 *
 */
class TraumaTagLib {

    // Viene archetypeId o (rmtype y idMarchingKey)
    // in: episodeId
    def resumenEpisodio = { attrs, body ->
    
       def composition = Composition.get( attrs.episodeId )
       if (!composition)
           throw new Exception("No se encuentra el episodio con id " + attrs.episodeId)

       out << '<div id="resumen_episodio">'
       
       out << '<h2>'+ message(code:'trauma.label.resumenEpisodio') +'</h2>'
       
       out << '<span>' + message(code:'trauma.list.label.startTime') + ': '
       out << render(template:"../trauma/DvDate", model:[date: composition.context.startTime]) + '<br/>'
       out << message(code:'trauma.list.label.endTime') + ': '
       out << render(template:"../trauma/DvDate", model:[date: composition.context.endTime])
       out << '</span>'

       //OJO: Solo funciona si el otherContext es ItemSingle y el value del Element es DvText
       out << '<span>' + message(code:'trauma.list.label.observations') + ': '
       out << composition.context.otherContext.item.value.value
       out << '</span>'
       
       out << '</div>'
    }
}
